#include <gtk/gtk.h>
#include <glade/glade.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

GladeXML *window;

enum
  {
	COL_FIRST_NAME = 0,
	COL_LAST_NAME,
	COL_YEAR_BORN,
	NUM_COLS
   };

int addColum(GtkWidget * treeview, char* title, char * type, int index)
{
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *column;

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes (title,
						     renderer,
						     type,
						     index,
						     NULL);
   gtk_tree_view_column_set_resizable(column, TRUE);

   gtk_tree_view_append_column (treeview, column);

   /*renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("NAME",
   						      renderer,
 						      "text",
						      COL_LAST_NAME,
						      NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);

  gtk_tree_view_append_column (treeview, column);
  */
  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("ADDRESS",
						     renderer,
						     "text",
						     COL_YEAR_BORN,
						     NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);

  gtk_tree_view_append_column (treeview, column);
}
int addRow()
{
	
}
int main(int argc, char **argv)
{

   gtk_init( &argc, &argv );
   
   window = glade_xml_new( "5.glade", NULL, NULL );
   glade_xml_signal_autoconnect( window );

   GtkWidget * treeview;
   treeview = glade_xml_get_widget(window, "treeview2");
   if(treeview == NULL)
   {
     printf("treeview is null \n ");
     exit(0);
   }

   GtkTreeModel *model;
   GtkListStore *liststore;
   GtkTreeIter iter;

   liststore = gtk_list_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);

   /* Append an empty row to the list store. Iter will point to the new row */
   gtk_list_store_append(liststore, &iter);

   /* Fill fields with some data */
   gtk_list_store_set (	liststore, 
			&iter,
   			COL_FIRST_NAME, "Joe",
   			COL_LAST_NAME, "Average",
   			COL_YEAR_BORN, (guint) 1970,
  			-1 );

   model = GTK_TREE_MODEL( liststore );
   gtk_tree_view_set_model(GTK_TREE_VIEW(treeview),model);
   g_object_unref (model);


   
  
  GtkTreeSelection *select = gtk_tree_view_get_selection (GTK_TREE_VIEW(treeview)); 

  printf("%d ", *select);

#ifdef DEBUG
   printf("window %x ", window);
#endif
   
   gtk_main();

   return 0;
}
